package models

import (
	"fmt"
	db "hulk-api/databases"
	"encoding/json"
	"github.com/garyburd/redigo/redis"
)

func redisSet(id int , val Status)  {
	fmt.Printf("现在状态是   %+v\n", val)
	redisconn := db.RedisPool.Get()
	defer redisconn.Close()

	if b,err := json.Marshal(val); err == nil {
		fmt.Println("开始改变任务状态，id: " , id)
		_,err =redisconn.Do("SET",id,string(b))
		if err != nil {
			fmt.Println("set redis key 失败 ,id: ",id , "  " , err.Error())
		}
	} else {
		fmt.Println("开始改变任务状态，id:", id ,err.Error())
	}

}




func redisGet(id int) (s string,err error) {
	redisconn := db.RedisPool.Get()
	defer redisconn.Close()
	s,err = redis.String(redisconn.Do("GET",id))
	if err != nil {
		fmt.Println("获取当前job状态错误：",err.Error())
	}
	return

}


